<?php
$this->breadcrumbs=array(
		'Mua nhạc cụ'=>array('/product'),
		$model->name,
);

?>
<div class="left">
	<h1 class="title">
		<?php echo $model->name; ?>
	</h1>
	<abbr class="date">Đăng bởi <span
		style="color: red; font-weight: bold;"><?php echo $model->user->username ?>
	</span> vào lúc: <?php echo date('H:i', $model->create_time); ?> ngày <?php echo date('d/m/Y', $model->create_time); ?>
	</abbr>

	<div style="margin-top: 20px; text-align: center">
		<?php 
		$thumb = '';
		if($model->image_id){
			$thumb = '/upload/images/thumb/product500/'.substr_replace($model->image->path,'',0,14);
			if(!is_file(Yii::getPathOfAlias('webroot').$thumb)){
				Yii::import('application.extensions.image.Image');
				$image = new Image(Yii::getPathOfAlias('webroot').'/'.$model->image->path);
				$image->resize(500, 300);
				if(!is_dir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product500/')){
					mkdir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product500/');
					chmod(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product500/',0777);
				}
				$image->save(Yii::getPathOfAlias('webroot').$thumb);
			}
		}
		?>
		<?php if($model->image_id): ?>
		<img src="<?php echo Yii::app()->baseUrl.$thumb; ?>">
		<?php endif?>

		<?php echo CHtml::ajaxButton("", $this->createUrl('addcart',array('id'=>$model->id)),array('success'=>'js:function(data){
				if(data.success){window.location = "'.$this->createUrl('cart').'"}
															}'),array('id'=>'btn_buy'))?>
	</div>
	<div style="margin: 20px 0px;">
		<?php echo $model->description; ?>
	</div>
	<div style="margin: 10px 0px;">
		<!-- AddThis Button BEGIN -->
		<div class="addthis_toolbox addthis_default_style ">
			<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
			<a class="addthis_button_tweet"></a> <a
				class="addthis_button_google_plusone" g:plusone:size="medium"></a> <a
				class="addthis_counter addthis_pill_style"></a>
		</div>
		<script type="text/javascript">//var addthis_config = {"data_track_addressbar":true};</script>
		<script type="text/javascript"
			src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f88f64654f5680c"></script>
		<!-- AddThis Button END -->
	</div>

		<?php
		/**
		 * @var $dataProvider CActiveDataProvider
		 * @var $dataFacility CActiveDataProvider
		 * @var $this TrainingController
		 */
		$this->widget('zii.widgets.CListView', array(
				'dataProvider' => $others,
				'itemView' => '_view',
				'id' => 'other-products',
				'enablePagination'=>false,
				'summaryText'=>'Sản phẩm khác',
				'itemsCssClass'=>'items clearfix'
				//'template' => "{items}\n{pager}",
		));
		?>

	<div id="comments">
		<?php if ($model->commentCount >= 1): ?>
		<h2>
			<?php echo $model->commentCount . ' Comments'; ?>
		</h2>

		<?php $this->renderPartial('_comments', array(
				'training' => $model,
				'comments' => $model->comments,
    )); ?>
		<?php endif; ?>

		<?php if (!Yii::app()->user->isGuest): ?>
		<h3 style="margin-top: 1em;">Gửi bình luận</h3>

		<?php if (Yii::app()->user->hasFlash('commentSubmitted')): ?>
		<div class="flash-success">
			<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
		</div>
		<?php else: ?>
		<?php $this->renderPartial('/comment/_form', array(
				'model' => $comment,
        )); ?>
		<?php endif; ?>
		<?php else: ?>
		<div>
			<?php echo CHtml::link('Đăng nhập', $this->createUrl('/site/login')); ?>
			để đăng bình luận.
		</div>
		<?php endif; ?>
        <div style="border-top: 1px solid #ccc">
            <h2 style="padding: 5px">Bình luận từ Facebook</h2>
            <div class="fb-comments" data-href="http://hocgioi.com.vn/lnt" data-num-posts="2" data-width="470"></div>
        </div>
	</div>
	
</div>
<div class="right">
	<?php
	$this->beginWidget('zii.widgets.CPortlet', array(
			'contentCssClass' => 'box-cart',
			'id'=>'cart-box'
	));
	$this->widget('CartBox');
	$this->endWidget();
	?>
	<?php
	$this->beginWidget('zii.widgets.CPortlet', array(
			'title' => 'Danh mục đàn',
			'id'=>'box-video-channel'
	));
	$this->widget('ProductCatList');
	$this->endWidget();
	?>

	<?php
	$this->beginWidget('zii.widgets.CPortlet', array('title'=>'Cơ sở đào tạo'));
	$this->widget('FacilityList', array());
	$this->endWidget();
	?>
</div>
<!-- comments -->

